package com.xu.strategy;

import com.xu.factory.*;

/**
 *
 * @author xudenghui
 * @create 2023-05-17 13:47
 **/
public class StrategyTest {

    public static void main(String[] args) {
        CashContext cashNormal = method1("正常收费");
        CashContext cashReturn = method1("满300返100");
        CashContext cashRebate = method1("打八折");
        System.out.println(cashNormal.getResult(300));
        System.out.println(cashReturn.getResult(300));
        System.out.println(cashRebate.getResult(300));

    }



    public static  CashContext method1(String cbxType){
        CashContext cc = null;

        switch (cbxType){
            case  "正常收费":
                cc = new CashContext(new CashNormal());
                break;
            case  "满300返100":
                cc = new CashContext(new CashReturn("300", "100"));
                break;
            case "打八折":
                cc = new CashContext(new CashRebate("0.8"));
                break;
        }
        return cc;
    }

}
